ToolbarPanel = function(){
	
	var btnTest = new Ext.Toolbar.Button({
		iconCls:'test-icon',
		tooltip: { title: 'Test', text: 'Test button, very usefull for debuging.' },
		handler:function(){
			Ext.ux.NotificationBox.msg('Click','You clicked the test button.');
			Ext.ux.Status.log({msg: 'Test', type: 'warning'});
			
		}
	});
	
	
	var btnEdit = new Ext.Toolbar.Button({
		text: 'Edit',
		iconCls:'edit-icon',
		menu: {
			items: [
				{
					text: 'Cut',
					iconCls: 'cut-icon'
				
				},{
					text: 'Copy',
					iconCls: 'copy-icon'
				
				},{
					text: 'Paste',
					iconCls: 'paste-icon'
				
				}
			]
		}
		
	});
	
	var btnFile = new Ext.Toolbar.Button({
		text: 'File',
		iconCls:'file-icon',
		menu: {
			items: [
				{
					text: 'Add Zone',
					iconCls: 'add-icon',
					handler: function() {
						Ext.getCmp('zonePanel').showWindow();
					}
				}, '-', {
					text: 'Print...',
					iconCls: 'print-icon'
				
				}, '-', {
					text: 'Import...',
					iconCls: 'import-icon'
				
				},{
					text: 'Export...',
					iconCls: 'export-icon'
				}, '-', {
					text: 'Donate',
					iconCls: 'donate-icon',
					handler: function() {
					
				
						if (Ext.get('donate') == null) {
							var tab = new Ext.ux.ManagedIframePanel({
								title: "Donate",
								id: 'donate',
								iconCls: 'donate-icon',
								loadMask:true,
								defaultSrc:'http://extbind.com/app/donate/',
								autoScroll:true
							});
							// show new tab
							Ext.getCmp("tabPanel").add(tab).show();
						} else {
							// tab already exists, switch focus to it
							Ext.getCmp('tabPanel').activate('donate');
						}
						
					
					}
				
				}, '-' , {
					text: 'Exit',
					iconCls: 'exit-icon'
				
				}
			]
		}
		
	});
	
	
	var btnTools = new Ext.Toolbar.Button({
		text: 'Tools',
		iconCls: 'tools-icon',
		menu : {
			items: [
				{
					text: 'DNS Lookup',
					iconCls: 'dnslookup-icon'
				}, '-' ,{
					text: 'intoDNS Report',
					iconCls: 'intodns-icon'
				}, '-', {
					text: 'Commands',
					iconCls: 'commands-icon',
					menu: {
						items: [
							{
								text: 'dig',
								handler: function() {
									console.debug('dig');
									win = new DigWindow();
									win.show();
									
								},
								iconCls: 'dig-icon'
							},{
								text: 'host',
								iconCls: 'host-icon'
							},{
								text: 'nslookup',
								iconCls: 'nslookup-icon'
							}
						
						]
					}
					
					
				}
			]
		}
	});
	
	var btnLogout = new Ext.Toolbar.Button({
		iconCls:'logout-icon',
		tooltip: { title: 'Logout', text: 'Close your session and return to the login screen.' },
		handler:function(){
			window.location.replace('logout.php');
		}
	});
	
	var btnWiki = new Ext.Toolbar.Button({
		iconCls:'wiki-icon',
		text:'Wiki',
		tooltip: { title: 'Wiki', text: 'The source of all knowlage.' },
		handler: function() {
			if (typeof Ext.getCmp('tab-wiki') == 'undefined') {
				// not created yet
				Ext.getCmp('tabPanel').add(new Ext.ux.ManagedIframePanel({
					title: "Wiki",
					id: 'tab-wiki',
					iconCls: 'wiki-icon',
					loadMask:true,
					closable:true,
					defaultSrc:'http://app.extbind.com/wiki/',
					autoScroll:true
				})).show(); // show tab
			} else {
				// tab already exists, just show it
				Ext.getCmp('tab-wiki').show();
			}
		}
	});
	
	var btnStatus = new Ext.Toolbar.Button({
		iconCls:'unknown-icon',
		id: 'btnStatus',
		tooltip: { title: 'Unknown', text: 'Unknown. Please wait...' },
		handler: function() {
				console.debug('moo');
				console.debug(ExtBIND.App);
				console.debug(ExtBIND.App.getPreferencesPanel());
			
		}
	});
	
	var btnBugReport = new Ext.Toolbar.Button({
		iconCls:'bugreport-icon',
		text:'Bug Report',
	//	tooltip: '<b>Bug Report</b><br/>Please let us know if you find a bug.',
		tooltip: { text:'Please let us know if you find a bug.', title:'Bug Report' },
		handler: function() {
			if (typeof Ext.getCmp('tab-bugreport') == 'undefined') {
				Ext.getCmp('tabPanel').add(new Ext.ux.ManagedIframePanel({
					id: 'tab-bugreport',
					title: 'Bug Report',
					closable:true,
					loadMask:true,
					autoScroll:true,
					defaultSrc:'http://app.extbind.com/bugreport/',
					iconCls: 'bugreport-icon'
				})).show(); // show tab
			} else {
				// tab already exists, just show it
				Ext.getCmp('tab-bugreport').show();
			}
		}
	});
	
	var btnHelp = new Ext.Toolbar.Button({
		text: 'Help',
	//	tooltip: {text:'Find the answer here.', title:'Help'},
		iconCls: 'help-icon',
		menu : {
			items: [
				{
					iconCls:'contents-icon',
					text:'Get Help Online...',
					handler: function() {
						if (typeof Ext.getCmp('tab-help') == 'undefined') {
							Ext.getCmp('tabPanel').add(new Ext.ux.ManagedIframePanel({
								id: 'tab-help',
								title: 'Help',
								closable:true,
								loadMask:true,
								autoScroll:true,
								defaultSrc:'http://app.extbind.com/help/',
								iconCls: 'contents-icon'
							})).show(); // show tab
						} else {
							// tab already exists, just show it
							Ext.getCmp('tab-help').show();
						}
					}

				},{
					iconCls:'translate-icon',
					text:'Translate This Application...',
					handler: function() {
						if (typeof Ext.getCmp('tab-translate') == 'undefined') {
							Ext.getCmp('tabPanel').add(new Ext.ux.ManagedIframePanel({
								id: 'tab-translate',
								title: 'Translate',
								closable:true,
								loadMask:true,
								autoScroll:true,
								defaultSrc:'http://app.extbind.com/translate/',
								iconCls: 'translate-icon'
							})).show(); // show tab
						} else {
							// tab already exists, just show it
							Ext.getCmp('tab-translate').show();
						}
					}

				},{
					iconCls:'contributors-icon',
					text:'Contributors',
					handler: function() {
						if (typeof Ext.getCmp('tab-contributors') == 'undefined') {
							Ext.getCmp('tabPanel').add(new Ext.ux.ManagedIframePanel({
								id: 'tab-contributors',
								title: 'Contributors',
								closable:true,
								loadMask:true,
								autoScroll:true,
								defaultSrc:'http://app.extbind.com/contributors/',
								iconCls: 'contributors-icon'
							})).show(); // show tab
						} else {
							// tab already exists, just show it
							Ext.getCmp('tab-contributors').show();
						}
					}
				}, '-',{
					iconCls:'update-icon',
					text:'Check for Updates...'
				}, '-', {
					iconCls:'about-icon',
					text:'About ExtBIND',
					handler: function() {
						win = new AboutWindow();
						win.show();
					}
				}
			]
		}
	});
	
	var toolbar = new Ext.Toolbar({
		id: 'toolbarPanel',
		items: [
			btnFile,
			'-',
			btnEdit,
			'-',
			btnTools,
			'-',
			btnWiki,
			'-',
			btnBugReport,
			'-',
			btnHelp,
			'-',
			btnStatus,
			btnLogout,
			'-',
			btnTest
		]
	});
	
	
	
	
	
	
	ToolbarPanel.superclass.constructor.call(this, {
		region:'north',
		height:26,
		margins:'0 0 5 0',
		items: toolbar
	});
	
/*	// public
	return {
		mooo: function() {
			var btnStatusUnknown = new Ext.Toolbar.Button({
				iconCls:'unkown-icon',
				tooltip: { title: 'Unknown', text: 'Unknown. Please wait...' },
				handler: function() {
						console.debug('unknown');
					
				}
			});
			
			return btnStatusUnknown;
		}
	
		
	};
*/
};





Ext.extend(ToolbarPanel, Ext.Panel, {
	setStatusUnknown: function() {
		btn = Ext.getCmp('btnStatus');
		btn.setIconClass('unkown-icon');
		btn.setTooltip({ title: 'Unknown', text: 'Unknown. Please wait...' });
		return true;
	}, setStatusOffline: function() {
		btn = Ext.getCmp('btnStatus');
		btn.setIconClass('offline-icon');
		btn.setTooltip({ title: 'Offline', text: 'Cannot contact extbind.com. Check your firewall.' });
		return true;
	}, setStatusOnline: function() {
		btn = Ext.getCmp('btnStatus');
		btn.setIconClass('online-icon');
		btn.setTooltip({ title: 'Online', text: 'Online. Everything is OK!' });
		return true;
	}
});
